package cn.wzvtc.common.exception;

import cn.wzvtc.common.dto.Result;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @author Shiwei Xu
 * @date 2020/5/27
 */
@RestControllerAdvice
public class MyExceptionHandler {

  @ExceptionHandler(MyException.class)
  public Result myExceptionHandler(MyException myEx) {
    String msg = myEx.getMsg();
    return Result.error(msg);
  }


  @ExceptionHandler(Exception.class)
  public Result defaultExceptionHandler(Exception myEx) {
    String msg = myEx.getMessage();
    return Result.error(msg);
  }

}
